//
//  AppearanceViewController.m
//  iOSCodeLearning
//
//  Created by TFAppleWork-Summer on 2018/3/20.
//  Copyright © 2018年 Ace. All rights reserved.
//

#import "AppearanceViewController.h"

@interface AppearanceViewController ()

@end

@implementation AppearanceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    for (NSInteger i = 0; i<3; i++) {
        UISwitch *s = [[UISwitch alloc]init];
        s.center = CGPointMake(100, 100 + (i*50));
        s.on = YES;
        [self.view addSubview:s];
    }
}
/*
  appearance ： 只能在控件显示之前设置，才有用
 
   夜间模式
 */
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    for (UISwitch *s  in self.view.subviews) {
//        if ([s isKindOfClass:[UISwitch class]]) {
//            s.onTintColor = [UIColor redColor];
//        }
//    }
    
    [self.view removeFromSuperview];
    
    UISwitch *s = [UISwitch appearance];
    s.onTintColor = [UIColor redColor];
    
    [[UIApplication sharedApplication].keyWindow addSubview:self.view];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
